
define(['config/appregister','jquery','domReady'],function(app,httpService){
    app.directive("jiaShare",function(){
        return {
            templateUrl:"app/business/home/directives/templates/share.html",
            scope:{
            	conf:"=confData"
            },
            link:function(scope,element,attrs){
            	/*var jiathis_config={
					data_track_clickback: false,
					summary:scope.conf.summary,
    				title:scope.conf.title,
				    appkey:{
				        "tsina":"5a847350da8d737f9443d1e2aedb1ed9",
				        "tqq":"40d32cfa124e6f2fc97abbac918c8c56",
				        "weixin":"83edb3fa7f5d632e82261595f738d683"
				    },
				    shortUrl:false,
				    hideMore:false
				}
            	console.log(jiathis_config.title)
                var ele = $('<script type="text/javascript" src="http://v3.jiathis.com/code/jia.js" charset="utf-8"></script>');
                setTimeout(function(){
					ele.insertAfter($('body'));
                },1000)*/
               	//var loc = scope.conf.url;
				var loc = window.location.url;
				var title = scope.conf.title;
				var summary = scope.conf.summary;
				scope.qqURL = 'http://www.jiathis.com/send/?webid=qzone&url='+loc+'&title='+title+'&summary='+summary;
				scope.sinaURL = 'http://www.jiathis.com/send/?webid=tsina&url='+loc+'&title='+title+'&summary='+summary;
				scope.weixinURL = 'http://www.jiathis.com/send/?webid=weixin&url='+loc+'&title='+title+'&summary='+summary;
				var bTag = true;
				$('.share-btn').on('click',function(){
					if(bTag){
						$('.jiathis_style').show();
					}else{
						$('.jiathis_style').hide();
					}
					bTag = !bTag;
				})
				//window.open(_shareUrl,'_blank','toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0,' + 'width=' + _width + ',height=' + _height + ',top=' + (screen.height-_height)/2 + ',left=' + (screen.width-_width)/2);
				//window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"16"},"share":{"bdSize":16}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];
				/*var jiathis_config = {
					boldNum:0,
					siteNum:3,
					showClose:false,
					url:"http://www.jiathis.com",
					title:"自定义TITLE #微博话题#",
					summary:"分享的文本摘要",
					pic:"自定义分享的图片连接地址",
					data_track_clickback:true,
					appkey:{
				        "tsina":"5a847350da8d737f9443d1e2aedb1ed9",
				        "tqq":"40d32cfa124e6f2fc97abbac918c8c56",
				        "tweixin":"83edb3fa7f5d632e82261595f738d683"
				    },
					ralateuid:{//是否启用回流量统计
					    "tsina":"您的新浪微博UID"
					},
					evt:{
					    "share":"用户自定义函数" ( 可以根据自己的命名规范来定义一个自定义函数，如：getEvent )
					        说明：evt参数可以得到用户的分享操作的相关信息。比如：用户分享的URL，用户分享到的媒体。但是，我们不能确定用
					        户是否真正成功的分享了内容，只能确定用户确实是点击了分享按钮……
					}
				}*/
            }
        }
    });
    
    app.directive("uiShare",function(){
		return {
			templateUrl:"app/business/home/directives/templates/uiShare.html",
			scope:{
            	conf:"=confData"
            },
			link:function(scope,element,attrs){
				var loc = window.location.href;
				var title = scope.conf.title;
				var summary = scope.conf.summary;
				console.log(loc)
             	scope.qqURL = 'http://www.jiathis.com/send/?webid=qzone&url='+loc+'&title='+title+'&summary='+summary;
               	scope.sinaURL = 'http://www.jiathis.com/send/?webid=tsina&url='+loc+'&title='+title+'&summary='+summary;
               	scope.weixinURL = 'http://www.jiathis.com/send/?webid=weixin&url='+loc+'&title='+title+'&summary='+summary;
				/*var ele = $('<script type="text/javascript" src="http://v3.jiathis.com/code/jia.js" charset="utf-8"></script>');
				ele.insertAfter($('body'));
				var loc = window.location.href;
				var jiathis_config={
					data_track_clickback: false,
					summary:scope.share.summary,
    				title:scope.share.title,
					appkey:{
						"tsina":"5a847350da8d737f9443d1e2aedb1ed9",
						"tqq":"40d32cfa124e6f2fc97abbac918c8c56",
						"tweixin":"83edb3fa7f5d632e82261595f738d683"
					},
					shortUrl:false,
					hideMore:false
				}*/
			}
		}
	})
});
